//
//  LoginAPI.swift
//  SwiftUI+MVVM+Repository
//
//  Created by 高强 on 2024/9/10.
//

import Moya

enum AuthAPI {
    case login(username: String, password: String);
}

extension AuthAPI: TargetType {
    
    
    var baseURL: URL {
        return URL(string: AppConfig.shared.baseURL)!
    }
    
    var path: String{
        switch self{
            case .login: return "/login"
        }
    }
    
    var method: Method {
        switch self{
            case .login :
                return .post
        }
    }
    
    var task: Task {
        switch self{
            case let .login(username, password):
                return .requestParameters(parameters: ["username": username, "password": password], encoding: JSONEncoding.default)
                
        }
    }
    
    var headers: [String : String]? {
        return  ["Content-type": "application/json"]
    }
    
    var sampleData: Data {
        return Data()
    }
}
